package thread;

import java.io.OutputStream;

/**使用匿名内部类创建线程*/
public class ThreadDemo3 {
    public static void main(String[] args) {
        //方式1:继承Thread重写run方法
        Thread t1 = new Thread(){
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("你是谁啊?");
                }
            }
        };
        //方式2:实现Runnable接口单独定义任务
        Runnable thread = new Thread();
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("开门,查水表的!");
            }
        });
        t1.start();
        t2.start();
    }
}
